package tests.gui;

//FrontEnd Plus GUI for JAD
//DeCompiled : MyEclipseKeyGen.class

import java.awt.Toolkit;
import java.text.*;
import java.util.Calendar;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;



public class MyEclipseKeyGen {

	private Display display;
	private Shell shell;
	private Group chooseVer_G;
	private Group proOrStd_G;
	private Button ver5_5_R;
	private Button ver5_5_P_R;
	private Button pro_B;
	private Button std_B;
	private Button generate_B;
	private Label sser_L;
	private Label NumOfLic_L;
	private Label ver_L;
	private Label ssc_L;
	private Text sser_T;
	private Text NumOfLic_T;
	private Text ver_T;
	private Text ssc_T;

	private MyEclipseKeyGen() {
		display = Display.getDefault();
		shell = new Shell(display, 192);
		shell.setImage(new Image(Display.getCurrent(), "Images/myeclipse.gif"));
		shell.setText("MyEclipseCrack");
		shell.setSize(253, 356);
		shell
				.setLocation(
						(Toolkit.getDefaultToolkit().getScreenSize().width - shell
								.getBounds().width) / 2,
						(Toolkit.getDefaultToolkit().getScreenSize().height - shell
								.getBounds().height) / 2);
		shell.open();
		chooseVer_G = new Group(shell, 0);
		chooseVer_G.setText("Choose Version");
		chooseVer_G.setBounds(10, 4, 230, 50);
		ver5_5_R = new Button(chooseVer_G, 16);
		ver5_5_R.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				ver_T.setText("");
				ver_T.setEditable(false);
			}
		});
		ver5_5_R.setSelection(true);
		ver5_5_R.setBounds(10, 20, 95, 20);
		ver5_5_R.setText("5.5GA && Last");
		ver5_5_P_R = new Button(chooseVer_G, 16);
		ver5_5_P_R.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				ver_T.setEditable(true);
				ver_T.setText("511");
			}
		});
		ver5_5_P_R.setBounds(110, 20, 115, 20);
		ver5_5_P_R.setText("5.5GA && Previous");

		proOrStd_G = new Group(shell, 0);
		proOrStd_G.setText("Professional OR Standard");
		proOrStd_G.setBounds(10, 60, 230, 50);
		pro_B = new Button(proOrStd_G, 16);
		pro_B.setSelection(true);
		pro_B.setBounds(10, 20, 95, 20);
		pro_B.setText("Professional");
		std_B = new Button(proOrStd_G, 16);
		std_B.setBounds(110, 20, 70, 20);
		std_B.setText("Standard");

		sser_L = new Label(shell, 0);
		sser_L.setText("Subscriber");
		sser_L.setBounds(10, 120, 60, 15);
		sser_T = new Text(shell, 2048);
		sser_T.setText(System.getProperty("user.name"));
		sser_T.setBounds(10, 135, 230, 20);

		NumOfLic_L = new Label(shell, 0);
		NumOfLic_L.setText("Number Of Licenses(Default 5, Max 999)");
		NumOfLic_L.setBounds(10, 165, 230, 15);
		NumOfLic_T = new Text(shell, 2048);
		NumOfLic_T.setText("5");
		NumOfLic_T.setBounds(10, 180, 230, 20);

		ver_L = new Label(shell, 0);
		ver_L.setText("Version");
		ver_L.setBounds(10, 210, 45, 15);
		ver_T = new Text(shell, 2048);
		ver_T.setEditable(false);
		ver_T.setBounds(10, 225, 230, 20);

		ssc_L = new Label(shell, 0);
		ssc_L.setText("Subscription Code");
		ssc_L.setBounds(10, 255, 105, 15);
		ssc_T = new Text(shell, 2048);
		ssc_T.setEditable(false);
		ssc_T.setBounds(10, 270, 230, 20);

		generate_B = new Button(shell, 0);
		generate_B.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent arg0) {
				String userId = sser_T.getText().trim();
				if (userId.equals("")) {
					userId = System.getProperty("user.name");
					sser_T.setText(userId);
				}
				String licenseNum = NumOfLic_T.getText().trim();
				if (licenseNum.equals("")) {
					licenseNum = "5";
					NumOfLic_T.setText("5");
				}
				String version = ver_T.getText().trim();
				if (version.equals(""))
					if (ver5_5_R.getSelection()) {
						version = "300";
						ver_T.setEditable(false);
					} else {
						version = "511";
						ver_T.setText(version);
					}
				ssc_T.setText(getSerial(userId, version, licenseNum, ver5_5_R
						.getSelection(), pro_B.getSelection()));
			}
		});
		generate_B.setText("Generate");
		generate_B.setBounds(150, 296, 90, 23);
		shell.layout();
		while (!shell.isDisposed())
			if (!display.readAndDispatch())
				display.sleep();
		display.dispose();
	}

	private String getSerial(String userId, String version, String licenseNum,
			boolean selected, boolean proORstd) {
		Calendar cal = Calendar.getInstance();
		cal.add(1, 3);
		cal.add(6, -1);
		NumberFormat nf = new DecimalFormat("000");
		licenseNum = nf.format(Integer.valueOf(licenseNum));
		String verTime = selected ? (new StringBuilder("-")).append(
				(new SimpleDateFormat("yyMMdd")).format(cal.getTime())).append(
				"0").toString() : "-9912310";
		String type = proORstd ? "YE3MP-" : "YE2MY-";
		String need = (new StringBuilder(String.valueOf(userId.substring(0, 1))))
				.append(type).append(version).append(licenseNum)
				.append(verTime).toString();
		String dx = (new StringBuilder(String.valueOf(need)))
				.append(
						"Decompiling this copyrighted software is "
								+ "a violation of both your license agreement "
								+ "and the Digital Millenium Copyright Act of 1998 "
								+ "(http://www.loc.gov/copyright/legislation/dmca.pdf). "
								+ "Under section 1204 of the DMCA, penalties range up to a $500,000 fine "
								+ "or up to five years imprisonment for a first offense. Think about it; "
								+ "pay for a license, avoid prosecution, and feel better about yourself.")
				.append(userId).toString();
		int suf = decode(dx);
		String code = (new StringBuilder(String.valueOf(need))).append(
				String.valueOf(suf)).toString();
		return change(code);
	}

	private int decode(String s) {
		int i = 0;
		char ac[] = s.toCharArray();
		int j = 0;
		for (int k = ac.length; j < k; j++)
			i = 31 * i + ac[j];

		return Math.abs(i);
	}

	private String change(String s) {
		byte abyte0[] = s.getBytes();
		char ac[] = new char[s.length()];
		int i = 0;
		for (int k = abyte0.length; i < k; i++) {
			int j = abyte0[i];
			if (j >= 48 && j <= 57)
				j = ((j - 48) + 5) % 10 + 48;
			else if (j >= 65 && j <= 90)
				j = ((j - 65) + 13) % 26 + 65;
			else if (j >= 97 && j <= 122)
				j = ((j - 97) + 13) % 26 + 97;
			ac[i] = (char) j;
		}

		return String.valueOf(ac);
	}

	public static void main(String args[]) {
		new MyEclipseKeyGen();
	}

}